<?php

namespace Extend\Log;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

class OperationLog {

    public static function addLog($fileName, $info){
        $logger = new Logger('operator');
        // 创建处理器
        $filepath = dirname(dirname(__DIR__))."/Log/".date("Ym")."/".date("Ymd")."/";
        $stream = new StreamHandler($filepath.$fileName, Logger::INFO);
        $logger->pushHandler($stream);

        $content = json_encode($info, JSON_UNESCAPED_UNICODE);
        $logger->info($content);
    }

}